import request from "@/plugins/request";

//应用列表接口

export function getAppList(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/list",
    method: "get",
    params: data,
  });
}

//应用详情 
export function getAppDetail(data: Record<string, any>) {
  return request({
    url: "/api/admin/app?appId=" + data.appId,
    method: "get",
  });
}

//应用类型列表接口
export function getApplicationTypeList(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/getApplicationTypeList",
    method: "get",
    params: data,
  });
}

//添加应用接口
export function postAddApp(data: Record<string, any>) {
  return request({
    url: "/api/admin/app",
    method: "post",
    data,
  });
}

//修改应用接口
export function putEditApp(data: Record<string, any>) {
  return request({
    url: "/api/admin/app",
    method: "put",
    data,
  });
}

//删除应用接口
export function deleteApp(data: Record<string, any>) {
  return request({
    url: "/api/admin/app",
    method: "delete",
    params: data,
  });
}

/****应用菜单接口 */

//添加应用菜单
export function postM1Menu(data: Record<string, any>) {
  return request({
    url: "/api/admin/menu",
    method: "post",
    data,
  });
}

//编辑更新菜单
export function putM1Menu(data: Record<string, any>) {
  return request({
    url: "/api/admin/menu",
    method: "put",
    data,
  });
}

//删除菜单
export function deleteM1Menu(data: Record<string, any>) {
  return request({
    url: "/api/admin/menu/" + data.id,
    method: "delete",
  });
}

//应用菜单树数据
export function getMenuTree(data?: Record<string, any>) {
  return request({
    url: "/api/admin/menu/tree",
    method: "get",
    params: data,
  });
}



//应用菜单树数据
export function getMenuSysCode(data?: Record<string, any>) {
  return request({
    url: "/api/admin/menu/sys/code",
    method: "get",
    params: data,
  });
}


//字典列表接口
export function getAppDictPage(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/page",
    method: "get",
    params: data,
  });
}

//新增字典
export function postDict(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict",
    method: "post",
    data,
  });
}

//编辑更新菜单
export function putDict(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict",
    method: "put",
    data,
  });
}

//删除菜单
export function deleteDict(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/" + data.id,
    method: "delete",
  });
}

// 字典项列表(树结构数据) 
export function getAppDictCode(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/item/list",
    method: "get",
    params: data,
  });
}

// 字典项列表 （普通列表数据）
export function getBaseList(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/item/getBaseList",
    method: "get",
    params: data,
  });
}

//新增字典项
export function postDictItem(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/item",
    method: "post",
    data,
  });
}

//编辑字典项
export function putDictItem(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/item",
    method: "put",
    data,
  });
}

//删除字典项
export function deleteDictItem(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/item/" + data.id,
    method: "delete",
  });
}
//批量删除字典项
export function deleteBatchDictItem(data: Record<string, any>) {
  return request({
    url: "/api/admin/dict/item/deleteBatch",
    method: "delete",
    params: data,
  });
}

//数据参数列表
export function getAppParamPage(data: Record<string, any>) {
  return request({
    url: "/api/admin/param/page",
    method: "get",
    params: data,
  });
}

//新增参数
export function postParam(data: Record<string, any>) {
  return request({
    url: "/api/admin/param",
    method: "post",
    data,
  });
}

//编辑更新参数
export function putParam(data: Record<string, any>) {
  return request({
    url: "/api/admin/param",
    method: "put",
    data,
  });
}

//删除参数
export function deleteParam(data: Record<string, any>) {
  return request({
    url: "/api/admin/param/" + data.publicId,
    method: "delete",
  });
}

//分页查询角色信息 
export function getAppRolePage(data: Record<string, any>) {
  return request({
    url: "/api/admin/role/page",
    method: "get",
    params: data,
  });
}

//新增角色
export function postRole(data: Record<string, any>) {
  return request({
    url: "/api/admin/role",
    method: "post",
    data,
  });
}

//编辑角色
export function putRole(data: Record<string, any>) {
  return request({
    url: "/api/admin/role",
    method: "put",
    data,
  });
}

//删除角色
export function deleteRole(data: Record<string, any>) {
  return request({
    url: "/api/admin/role?roleCode=" + data.roleCode,
    method: "delete",
  });
}

//查询系统菜单树形结构(不包含禁用, 包含按钮) 
export function getSystemMenus(data?: Record<string, any>) {
  return request({
    url: "/api/admin/menu/systemMenus/" + data.sysCode,
    method: "get",
  });
}

/**更新角色菜单权限 */
export function putRoleMenu(data: Record<string, any>) {
  return request({
    url: "/api/admin/role/menu",
    method: "put",
    data,
  });
}

/**返回角色的菜单集合(不包含禁用以及按钮)  */
export function getRoleMenuTree(data: Record<string, any>) {
  return request({
    url: "/api/admin/menu/tree/" + data.roleCode,
    method: "get",
  });
}
//

//根据编码获取应用详情 
export function getDetailAppCode(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/getDetailByAppCode?appCode=" + data.appCode,
    method: "get",
  });
}

//获取应用详情 
export function getDetailApp(data: Record<string, any>) {
  return request({
    url: "/api/admin/app?appId=" + data.appId,
    method: "get",
  });
}

//访问授权-查看应用授权主体id数组 
export function getSysBindFirmIds(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/getBindFirmIds?appId=" + data.appId,
    method: "get",
  });
}

//访问授权-查看应用授权主体id数组 
export function getBindFirmIds(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/getBindFirmIds",
    method: "get",
    params:data
  });
}

//访问授权-查询主体绑定的应用
export function getFirmAppList(data: Record<string, any>) {
  return request({
    url: "/api/admin/firmApp/getFirmAppList",
    method: "get",
    params: data,
  });
}

/**解除绑定应用授权主体*/
export function putAppUnBindFirm(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/unBindFirm",
    method: "put",
    data,
  });
}

//查看应用绑定身份源列表 
export function GetBindSisList(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/getBindSisList",
    method: "get",
    params: data,
  });
}

//获取菜单树型数据 
export function getUserTree(data: Record<string, any>) {
  return request({
    url: "/api/admin/menu/userTree",
    method: "get",
    params: data,
  });
}
//批量删除
export function deleteBatch(data: Record<string, any>) {
 return request({
   url: "/api/admin/menu/deleteBatch",
   method: "delete",
   params: data,
 });
}
// 刷新应用秘钥  
export function getRefreshSecret(data: Record<string, any>) {
  return request({
    url: "/api/admin/app/refreshSecret",
    method: "get",
    params: data,
  });
}